package com.words.dao;

import com.words.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserDao {
    //查询
    @Select("select * from user where username = #{username} and password= #{password}")
    User login(@Param("username") String username, @Param("password") String password);

    //增加
    //这个user表里面的一个字段id是个自增长字段，但要保持有3个赋值，则应该填null占位
    @Insert("insert into user values( null,#{username}, #{password})")
    void register(@Param("username") String username, @Param("password") String password);

    //删除
    @Delete("delete from user where username = #{username}")
    void delete(@Param("username") String username);

    //按账号查询
    @Select("select * from user where username = #{username}")
    User queryByUsername(@Param("username") String username);

    //按编号查询
    @Select("select * from user where id = #{id}")
    User queryById(@Param("id")int id);
}
